﻿namespace Devonline.Entity;

/// <summary>
/// 通用身份抽象基类
/// 字符串形式默认实现
/// </summary>
public abstract class Identity : Identity<string>, IIdentity, IEntitySet, IEntitySetWithCreate, IEntitySetWithCreateAndUpdate
{
    /// <summary>
    /// 通用附件集合, NotMapped Attachments 用于记录实体对象上上传的附件
    /// </summary>
    [NotMapped]
    public virtual ICollection<Attachment>? Attachments { get; set; }
}

/// <summary>
/// 通用身份抽象基类
/// </summary>
public abstract class Identity<TKey> : EntitySetWithCreateAndUpdate<TKey>, IIdentity<TKey>, IEntitySet<TKey>, IEntitySetWithCreate<TKey>, IEntitySetWithCreateAndUpdate<TKey> where TKey : IConvertible
{
    /// <summary>
    /// 名称
    /// </summary>
    [Column("name"), Required, MaxLength(256), DisplayName("名称"), Excel]
    public virtual string? Name { get; set; }
    /// <summary>
    /// 昵称
    /// </summary>
    [Column("alias"), MaxLength(256), DisplayName("昵称"), Excel]
    public virtual string? Alias { get; set; }
    /// <summary>
    /// 头像
    /// </summary>
    [Column("image"), MaxLength(256), DisplayName("头像"), BusinessType(IsAttachment = true), Excel]
    public virtual string? Image { get; set; }
    /// <summary>
    /// 身份授权类型
    /// </summary>
    [Column("type", TypeName = "VARCHAR(16)"), DisplayName("授权类型"), Required, DefaultValue(AuthorizeType.Internal), Excel]
    public virtual AuthorizeType Type { get; set; }
}